package com.evil.kingdom.controller.core;

import com.evil.common.core.entity.R;
import com.evil.kingdom.pojo.entity.core.Arm;
import com.evil.kingdom.service.core.ArmService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 武器
 *
 * @author liyang
 * @date 2024-05-22 17:11
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/arm")
public class ArmController {

    private final ArmService armService;

    /**
     * 初始化武器
     *
     * @return R
     */
    @RequestMapping("/init")
    public R<String> init(String suffix) {
        armService.init(suffix);
        return R.success();
    }

    /**
     * 新增武器
     *
     * @param arm arm
     * @return R
     */
    @PostMapping("/add")
    public R<Arm> add(@RequestBody @Validated Arm arm) {
        return R.success(armService.add(arm));
    }

    /**
     * 查询武器
     *
     * @param name name
     * @return R
     */
    @RequestMapping("/find-by-name")
    public R<Arm> findByName(String name) {
        return R.success(armService.findByName(name));
    }
}
